package com.alan.wifishare.view.impl.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.alan.wifishare.R;
import com.alan.wifishare.presenter.CNTBindLinkPS;
import com.alan.wifishare.view.BaseActivity;
import com.alan.wifishare.view.impl.ActivityJumpUtil;
import com.alan.wifishare.view.iview.IVCNTBindLink;

/**
 * @className: CNTBindLinkSubmitActivity
 * @describtion: CNTBindLinkSubmitActivity
 * @author: AlanWang
 * @email: 850267876@qq.com
 * @time: 2016/5/4 09:29
 */
public class CNTBindLinkSubmitActivity extends BaseActivity implements IVCNTBindLink, View.OnClickListener {

    private CNTBindLinkPS cntBindLinkPS = null;
    private String deviceInfo = "";
    private TextView cntBindLinkSubmitDeviceTv;
    private Button cntBindLinkSubmitBackBtn;
    private Button cntBindLinkSubmitSubmitBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cnt_bind_link_submit_layout);
        cntBindLinkPS = new CNTBindLinkPS(this);
        initView();
    }

    @Override
    protected void initView() {
        Bundle bundle = getIntent().getExtras();
        deviceInfo = bundle.getString(ActivityJumpUtil.Extra.DEVICE_INFO);
        cntBindLinkSubmitDeviceTv = (TextView)findViewById(R.id.cntBindLinkSubmitDeviceTv);
        cntBindLinkSubmitBackBtn = (Button)findViewById(R.id.cntBindLinkSubmitBackBtn);
        cntBindLinkSubmitSubmitBtn = (Button)findViewById(R.id.cntBindLinkSubmitSubmitBtn);
        cntBindLinkSubmitDeviceTv.setText(deviceInfo);
        cntBindLinkSubmitBackBtn.setOnClickListener(this);
        cntBindLinkSubmitSubmitBtn.setOnClickListener(this);
    }

    @Override
    public String getDeviceInfo() {
        return deviceInfo;
    }

    @Override
    public void bindDeviceSuccess() {
        toastMsg("绑定成功");
        this.finish();
    }

    @Override
    public void showProgress() {

    }

    @Override
    public void hideProgress() {

    }

    @Override
    public void toastMsg(String msg) {
        toastMsgShort(msg);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.cntBindLinkSubmitBackBtn:
                CNTBindLinkSubmitActivity.this.finish();
                break;
            case R.id.cntBindLinkSubmitSubmitBtn:
                cntBindLinkPS.bindDevice();
                break;
            default:
                break;
        }
    }
}
